// 用户相关的请求模块

import request from '@/utils/request'

// 用户登录
export const login = data => {
    return request({
        method: 'POST',
        url: '/app/v1_0/authorizations',
        data
    })
}

// 发送短信验证码
export const sendMes = mobile => {
    return request({
        method: 'GET',
        url: `/app/v1_0/sms/codes/${mobile}`
    })
}

// 获取用户信息
export const getUserInfo = () => {
    return request({
        method: 'GET',
        url: '/app/v1_0/user'
    })
}

// 获取文章频道列表
export const getUserChannel = () => {
    return request({
        method: 'GET',
        url: '/app/v1_0/user/channels'
    })
}

// 获取用户个人资料
export const getUserProfile = () => {
    return request({
        method: 'GET',
        url: '/app/v1_0/user/profile'
    })
}

// 修改用户个人资料
export const updateUserProfile = data => {
    return request({
        method: 'PATCH',
        url: '/app/v1_0/user/profile',
        data
    })
}

// 修改用户照片
export const updateUserPhoto = data => {
    return request({
        method: 'PATCH',
        url: '/app/v1_0/user/photo',
        data
    })
}

// 获取用户收藏列表
export const getUserCollect = params => {
    return request({
        method: 'GET',
        url: '/app/v1_0/article/collections',
        params
    })
}

// 获取用户阅读历史
export const getUserHistory = params => {
    return request({
        method: 'GET',
        url: '/app/v1_0/user/histories',
        params
    })
}

// 获取用户的关注列表
export const getUserFollow = params => {
    return request({
        method: 'GET',
        url: '/app/v1_0/user/followings',
        params
    })
}

// 获取用户的粉丝列表
export const getUserFans = params => {
    return request({
        method: 'GET',
        url: '/app/v1_0/user/followers',
        params
    })
}

// 关注用户
export const toBeFans = target => {
    return request({
        method: 'POST',
        url: '/app/v1_0/user/followings',
        data: {
            target
        }
    })
}

// 取消关注用户
export const notFans = target => {
    return request({
        method: 'DELETE',
        url: `/app/v1_0/user/followings/${target}`
    })
}
